package com.avic.rong.adapter.vadio_adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.avic.rong.R;

import java.util.List;

/**
 * Created by TSJ-2018-0492 on 2019/9/24.
 */

public class RecyclerNormalAdapter extends RecyclerView.Adapter {

    private final static String TAG = "RecyclerBaseAdapter";


    private List<VideoModel> itemDataList = null;

    private Context context = null;


    public RecyclerNormalAdapter(Context context, List<VideoModel> itemDataList) {

        this.itemDataList = itemDataList;

        this.context = context;

    }


    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View v = LayoutInflater.from(context).inflate(R.layout.layout_vadio_item, viewGroup, false);
         RecyclerView.ViewHolder holder = new RecyclerItemNormalHolder(context, v);
        return holder;
    }

    @Override

    public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {

        RecyclerItemNormalHolder recyclerItemViewHolder = (RecyclerItemNormalHolder) holder;

        recyclerItemViewHolder.setRecyclerBaseAdapter(this);
        recyclerItemViewHolder.onBind(position, itemDataList.get(position));

    }


    @Override

    public int getItemCount() {

        return itemDataList.size();

    }


    @Override

    public int getItemViewType(int position) {

        return 1;

    }


    public void setListData(List<VideoModel> data) {

        itemDataList = data;

        notifyDataSetChanged();

    }
}
